package com.exsun.gateway.jt809.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.kafka.config.KafkaListenerContainerFactory;
import org.springframework.kafka.core.KafkaTemplate;

@Configuration
public class GroupBean {

    @Autowired
    KafkaProducerConfig kafkaProducerConfig;

    @Bean(name = "JT809ProducerKafkaTemplate")
    @Primary
    public KafkaTemplate<String, String> kafkaTemplate() {
        return kafkaProducerConfig.kafkaTemplate();
    }

    @Autowired
    private KafkaConsumerConfig kafkaConsumerConfig;

    @Value("${jt808handlecenter.kafka.consumer.gps809Group.id}")
    private String gps809Group;
    @Value("${jt808handlecenter.kafka.consumer.register809Group.id}")
    private String register809Group;
    @Value("${jt808handlecenter.kafka.consumer.authentication809Group.id}")
    private String authentication809Group;
    @Value("${jt808handlecenter.kafka.consumer.media809Group.id}")
    private String media809Group;
    @Value("${jt808handlecenter.kafka.consumer.link809Group.id}")
    private String link809Group;
    @Value("${jt808handlecenter.kafka.consumer.distributeToJT809Group.id}")
    private String distributeToJT809Group;
    @Value("${jt808handlecenter.kafka.consumer.mediaFileListGroup.id}")
    private String mediaFileListGroup;
    @Value("${jt808handlecenter.kafka.consumer.vehicleRegister809Group.id}")
    private String vehicleRegister809Group;

    @Value("${jt808handlecenter.kafka.consumer.PushDataToPlatform809Group.id}")
    private String PushDataToPlatform809Group;




    @Bean(name = "gpsData809Factory")
    @Primary
    public KafkaListenerContainerFactory<?> gpsData809ConsumerFactory() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(gps809Group);
    }

    @Bean(name = "register809Factory")
    @Primary
    public KafkaListenerContainerFactory<?> register809ConsumerFactory() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(register809Group);
    }

    @Bean(name = "authentication809Factory")
    @Primary
    public KafkaListenerContainerFactory<?> authentication809Factory() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(authentication809Group);
    }

    @Bean(name = "mediaDataFactory")
    @Primary
    public KafkaListenerContainerFactory<?> mediaData809ConsumerFactory() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(media809Group);
    }

    @Bean(name = "link809Factory")
    @Primary
    public KafkaListenerContainerFactory<?> link809ConsumerFactory() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(link809Group);
    }

    @Bean(name = "distributeToJT809Factory")
    @Primary
    public KafkaListenerContainerFactory<?> distributeToJT809ConsumerFactory() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(distributeToJT809Group);
    }

    @Bean(name = "mediaFileListFactory")
    @Primary
    public KafkaListenerContainerFactory<?> mediaFileListConsumerFactory() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(mediaFileListGroup);
    }
    @Bean(name = "vehicleRegister809GroupFactory")
    @Primary
    public KafkaListenerContainerFactory<?> vehicleRegisterConsumerFactory() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(vehicleRegister809Group);
    }

    @Bean(name = "PushDataToPlatform809GroupFactory")
    @Primary
    public KafkaListenerContainerFactory<?> PushDataToPlatformConsumerFactory() {
        return kafkaConsumerConfig.batchRecordConsumerFactoryByGroudid(PushDataToPlatform809Group);
    }


}


